<?php
namespace Admin\Controller;
class BorrowingController extends AdminBaseController
{
   public function index()
    {
        if(session('auid')==null){
            $this->display('index/login');
            exit();
        }
        $this->display('borrowing/index');
        
    }
    public function borrowinglist(){
		 if(session('auid')==null){
		       $this->display('index/login');
		       exit();
		   }
		  $page=I('page',1);
		  $rows=I('rows',50);
		  $start=($page-1)*$rows;
		  $sql='  SELECT a.loanduid,b.username,c.name,a.money,a.persionnum,a.rpersionum,a.status,a.interest,a.penalty,a.expiredate,a.createdate,a.mangrate,a.rate,a.full_time,a.loanid,a.investid,a.domtypeid,a.cred_code,a.is_mos FROM dd_cred_flow a LEFT JOIN dd_user b ON a.investuid = b.id LEFT JOIN dd_domain_type c ON  a.domtypeid = c.id ORDER BY a.createdate LIMIT '.$start.','.$rows;
		    $dao = M();
		    $list = $dao->query($sql);   
		    $count = M('CredFlow')->count();
		    $map=array(
		        'rows'=>$list,
		        'total'=>$count
		    );
		    $this->ajaxReturn($map,'JSON');
		    exit();
   }


    public function investmentlist(){
    	//echo '---------';exit();
    	     if(session('auid')==null){
             $this->display('index/login');
             exit();
        }
          $page=I('page',1);
		  $rows=I('rows',50);
		  $start=($page-1)*$rows;
		  $sql='SELECT b.username,a.uid,a.tovalue,a.tovalue,a.term_begin,a.term_end,a.create_time,a.is_auto,a.descrp FROM dd_investor_info a LEFT JOIN dd_user b ON  a.uid=b.id  ORDER BY a.create_time LIMIT '.$start.','.$rows;
		 
		    $dao = M();
		    $list = $dao->query($sql);   
		    $count = M('InvestorInfo')->count();
		    $map=array(
		        'rows'=>$list,
		        'total'=>$count
		    );
		    $this->ajaxReturn($map,'JSON');
		    exit();
    }

    public function lendlist(){
    	     if(session('auid')==null){
            $this->display('index/login');
            exit();
        }
          $page=I('page',1);
		  $rows=I('rows',50);
		  $start=($page-1)*$rows;
		  $sql='SELECT a.title,b.username,c.name,a.uid,a.money,a.tovalue,a.tim_type,a.rate,a.term,a. STATUS,a.full_time,a.create_time,a.descrp,a.overtime,a.domainnum,a.domaintypeid,a.cred_code FROM dd_loader_info a LEFT JOIN dd_user b ON a.uid = b.id LEFT JOIN dd_domain_type c ON a.domaintypeid = c.id ORDER BY a.create_time LIMIT '.$start.','.$rows;
		    $dao = M();
		    $list = $dao->query($sql);   
		    $count = M('LoaderInfo')->count();
		    $map=array(
		        'rows'=>$list,
		        'total'=>$count
		    );
		    $this->ajaxReturn($map,'JSON');
		    exit();
    }
    

}